/*
 *  Copyright (C) 2010 Glauco
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.swing.components.panel.layouts;

import javax.swing.GroupLayout;
import javax.swing.JPanel;
import org.balisunrise.swing.components.panel.LayoutBuilder;

/**
 * Constrói o layout para o editor de entidades.
 *
 * @author Glauco
 */
public class EditorLayoutBuilder implements LayoutBuilder{

    private JPanel messagePanel;
    private JPanel entityPanel;
    private JPanel actionPanel;

    public JPanel getActionPanel() {
        return actionPanel;
    }

    public void setActionPanel(JPanel actionPanel) {
        this.actionPanel = actionPanel;
    }

    public JPanel getEntityPanel() {
        return entityPanel;
    }

    public void setEntityPanel(JPanel entityPanel) {
        this.entityPanel = entityPanel;
    }

    public JPanel getMessagePanel() {
        return messagePanel;
    }

    public void setMessagePanel(JPanel messagePanel) {
        this.messagePanel = messagePanel;
    }

    /**
     * Controí o layout para editor.<br>
     * Deve haver trêz (3) componentes na lista, o primeiro deve ser a
     * Representação Visual (RV) do Messenger, o segundo deve ser a RV do 
     * EntityPanel e o terceiro deve ser a RV das ações do editor.
     * 
     * @param panel Painel do Editor.
     * @param components Lista de Componentes do painel.
     * @throws BuilderException
     */
    @Override
    public void buildLayout(JPanel panel) {

        panel.removeAll();
        GroupLayout layout = new GroupLayout(panel);
        panel.setLayout(layout);

        // HORIZONTAL
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(messagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, messagePanel.getPreferredSize().width, Short.MAX_VALUE)
            .addComponent(entityPanel, javax.swing.GroupLayout.DEFAULT_SIZE, entityPanel.getPreferredSize().width, Short.MAX_VALUE)
            .addComponent(actionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        // VERTICAL
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(messagePanel, 75, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE)
                .addComponent(entityPanel, 200, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(actionPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }

}
